/**
 *
 */
package com.naiterui.ehp.bs.doctor.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.doctor.service.ILoginService;
import com.naiterui.ehp.bs.doctor.vo.DeviceVerifyVO;


/**
 * 设备校验
 * @author guoyongxiang
 * @since 1.0.0
 */
@Api(tags = {SwaggerTag.DOCTOR + SwaggerTag.USER_ACCOUNT})
@RequestMapping("ad/device")
@Controller
public class AdDeviceVerifyController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AdDeviceVerifyController.class);

    @Autowired
    private ILoginService loginService;

    @ApiOperation(value = "登录设备校验(登录互踢)", notes = "传入设备标识校验是否与上次登录设备不同(每次登录后或切换前台时调用)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "doctorId", value = "医生ID", dataType = "Long", paramType = "query", required = true),
            @ApiImplicitParam(name = "deviceSN", value = "设备编号(设备唯一标识)", dataType = "Long", paramType = "query", required = true),
            @ApiImplicitParam(name = "_model", value = "机型", dataType = "Long", paramType = "query"),
    })
    @RequestMapping(value = "verify",method = {RequestMethod.GET, RequestMethod.POST} )
    @ResponseBody
    public DeviceVerifyVO verify(Long doctorId, String deviceSN, @RequestHeader(required = false) String _model) throws BusinessException {
        LOGGER.info("into the method verify. doctorId=" + doctorId + ",deviceSN=" + deviceSN + ",model=" + _model);
        return this.loginService.getVerifyInfo(doctorId, deviceSN);
    }
}
